package com.springboot.springbootlogindemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.springboot.springbootlogindemo.domain.Singer;
import com.springboot.springbootlogindemo.domain.User;
import com.springboot.springbootlogindemo.service.SingerService;
import com.springboot.springbootlogindemo.utils.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.*;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;

/**
 * 歌手控制类
 */
@RestController
@RequestMapping("/singer")
public class SingerController {

    @Resource
    private SingerService singerService;

    /**
     * 添加歌手
     * @param singer
     * @return
     */
    @PostMapping("/addSinger")
    public Result addSinger(@RequestBody Singer singer){
        return singerService.addSinger(singer);
    }

    /**
     * 更新歌手信息
     * @param singer
     * @return
     */
    @PostMapping("/updateSinger")
    public Result updateSinger(@RequestBody Singer singer){
        return singerService.updateSinger(singer);
    }

    /**
     * 删除歌手
     * @param singer
     * @return
     */
    @PostMapping("/deleteSinger")
    public Result deleteSinger(@RequestBody Singer singer){
        return singerService.deleteSinger(singer);
    }

    /**
     * 获取所有歌手
     * @return
     */
    @GetMapping("/getAll")
    public Result getAllSingers(){
        return singerService.getAll();
    }

    /**
     * 根据歌手姓名查找歌手
     * @param name
     * @return
     */
    @GetMapping("/findSingerByName")
    public Result findSingerByName(@RequestParam String name){
        return singerService.findSignerByName(name);
    }


}
